<template>
    <el-dialog   :visible.sync="showdetail" width="60%" :before-close="handleClose">
            <el-form ref="form" :model="form" label-width="120px" label-position="left">
              <div class="title">订单信息</div>
                <el-row :gutter="20">
                     <el-col :span="12">
                         <el-form-item label="订单归属企业">
                          <el-select v-model="form.declarationInfo.orderOrg.id" style="width:100%;">
                                <el-option
                                v-for="item in companylist"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                     </el-col>
                     <el-col :span="12">
                          <el-form-item label="订单真实交易平台">
                              <el-select v-model="form.ebPlatform.id" style="width:100%;">
                                <el-option
                                v-for="item in ebPlatformlist"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                                </el-option>
                            </el-select>
                             <!-- <el-input v-model="form.ebPlatform.name"></el-input> -->
                        </el-form-item>
                     </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                     <el-form-item label="商家订单号">
                             <el-input v-model="form.tradeInfo.orderNo"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="8">
                     <el-form-item label="商品总价">
                             <el-input v-model="form.tradeInfo.goodsTotalAmount"></el-input>
                        </el-form-item>
                    </el-col>
                     <el-col :span="8">
                     <el-form-item label="运费">
                             <el-input v-model="form.tradeInfo.freight"></el-input>
                        </el-form-item>
                    </el-col>
                     <el-col :span="8">
                     <el-form-item label="保费">
                             <el-input v-model="form.tradeInfo.insureFee"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
               <el-row>
                    <el-col :span="8">
                     <el-form-item label="预计税款">
                             <el-input v-model="form.tradeInfo.taxTotal"></el-input>
                        </el-form-item>
                    </el-col>
                     <el-col :span="8">
                     <el-form-item label="订单付款总额">
                             <el-input v-model="form.tradeInfo.totalAmount"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="折扣">
                             <el-input v-model="form.tradeInfo.discount"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row> 
                <el-row>
                     <el-col :span="8">
                     <el-form-item label="贸易国">
                          <el-select v-model="form.tradeInfo.tradCounty" >
                                <el-option
                                v-for="item in countries"
                                :key="item.hscode"
                                :label="item.country"
                                :value="item.hscode">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                     <el-col :span="8">
                     <el-form-item label="进口模式">
                             <el-input v-model="form.tradeInfo.tradeMode"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="重量">
                             <el-input v-model="form.tradeInfo.totalWeight"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                 <el-row>
                     <el-col :span="12">
                     <el-form-item label="支付单号">
                             <el-input v-model="form.tradeInfo.payOrderId"></el-input>
                        </el-form-item>
                    </el-col>
                     <el-col :span="12">
                     <el-form-item label="支付渠道">
                             <el-input v-model="form.tradeInfo.payChannel"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <div class="title">购买人信息</div>
                   <el-row :gutter="20">
                     <el-col :span="12">
                         <el-form-item label="交易平台注册号">
                             <el-input v-model="form.buyerInfo.buyerRegNo"></el-input>
                        </el-form-item>
                     </el-col>
                     <el-col :span="12">
                          <el-form-item label="姓名">
                             <el-input v-model="form.buyerInfo.buyerName"></el-input>
                        </el-form-item>
                     </el-col>
                </el-row>
                <el-row :gutter="20">
                     <el-col :span="12">
                         <el-form-item label="身份号">
                             <el-input v-model="form.buyerInfo.buyerIdNumber"></el-input>
                        </el-form-item>
                     </el-col>
                     <el-col :span="12">
                          <el-form-item label="手机号">
                             <el-input v-model="form.buyerInfo.buyerTel"></el-input>
                        </el-form-item>
                     </el-col>
                </el-row>
                 <div class="title">申报信息</div>
                 <el-row :gutter="20">
                     <el-col :span="12">
                         <el-form-item label="电商企业">
                                <el-select v-model="form.declarationInfo.orderOrg.id" style="width:100%;">
                                <el-option
                                v-for="item in companylist"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                     </el-col>
                     <el-col :span="12">
                          <el-form-item label="电商平台">
                                 <el-select v-model="form.declarationInfo.orderPlatformOrg.id" style="width:100%;">
                                <el-option
                                v-for="item in companylist"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                                </el-option>
                            </el-select>
                             <!-- <el-input v-model="form.declarationInfo.orderPlatformOrg.name"></el-input> -->
                        </el-form-item>
                     </el-col>
                </el-row>
                <el-row :gutter="20">
                     <el-col :span="12">
                         <el-form-item label="物流企业">
                                <el-select v-model="form.declarationInfo.logisticsOrg.id" style="width:100%;">
                                <el-option
                                v-for="item in companylist"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                                </el-option>
                            </el-select>
                             <!-- <el-input v-model="form.declarationInfo.logisticsOrg.name"></el-input> -->
                        </el-form-item>
                     </el-col>
                     <el-col :span="12">
                          <el-form-item label="支付企业">
                             <!-- <el-input v-model="form.declarationInfo.paymentOrg.name"></el-input> -->
                                <el-select v-model="form.declarationInfo.paymentOrg.id" style="width:100%;">
                                <el-option
                                v-for="item in companylist"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                     </el-col>
                </el-row>
                <el-row :gutter="20">
                     <el-col :span="12">
                         <el-form-item label="清单申报企业">
                              <el-select v-model="form.declarationInfo.invetoryOrg.id" style="width:100%;">
                                <el-option
                                v-for="item in companylist"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                     </el-col>
                     <el-col :span="12">
                         <el-form-item label="通关渠道">
                              <el-select v-model="form.reportDataChannel.id" style="width:100%;">
                                <el-option
                                v-for="item in channels"
                                :key="item.id"
                                :label="item.name"
                                :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                     </el-col>
                </el-row>
                <div class="title">订单信息</div>
                 <el-row :gutter="20">
                     <el-col :span="6">
                        备案信息
                     </el-col>
                     <el-col :span="3">
                        税前单价
                     </el-col>
                     <el-col :span="3">
                        销售计量单位
                     </el-col>
                     <el-col :span="3">
                        销售实际数量
                     </el-col>
                     <el-col :span="3">
                        第一计量数量
                     </el-col>
                     <el-col :span="3">
                       第二计量数量
                     </el-col>
                     <el-col :span="3">
                       适用消费税
                     </el-col>
                </el-row>
                <el-row :gutter="20" v-for="item in form.items" :key="item.id">
                     <el-col :span="6">
                         {{item.registerGoodsInfo.name}}
                     </el-col>
                     <el-col :span="3">
                         <el-input v-model="item.price"></el-input>
                     </el-col>
                     <el-col :span="3">
                         <el-input v-model="item.unit"></el-input>
                     </el-col>
                     <el-col :span="3">
                          <el-input v-model="item.qty"></el-input>
                     </el-col>
                     <el-col :span="3">
                         <el-input v-model="item.qty1"></el-input>
                     </el-col>
                     <el-col :span="3">
                        <el-input v-model="item.qty2"></el-input>
                     </el-col>
                     <el-col :span="3">
                         <el-input v-model="item.condConsRates"></el-input>
                     </el-col>
                </el-row>
            </el-form>
            <span slot="footer" class="dialog-footer"> 
                <el-button type="primary" plain @click="editForm()">修改</el-button>
                <!-- <el-button type="primary" @click="saveEditform(false)">拒绝</el-button> -->
                <el-button @click="handleClose">取 消</el-button>
            </span>
        </el-dialog>
</template>    
<script>
import jsondata from './country.js'
import {QueryOrder,ModifyOrder} from '@/api/goods';
import {QueryChannel} from '@/api/company';
export default {
    name:'details',
    props:["selectId","showdetail","ebPlatformlist","companylist"],
    data(){
        return{
           countries:jsondata.data,
        //    companylist:[],
        //    ebPlatformlist:[],
           form:{},
           channels:[]
        }
    },
    created(){
          var id=this.selectId;
          this.getData(id)
          QueryChannel({resultType:"list",}).then(res=>{
            this.channels=res.data       
            })
    },
    methods:{
        getData(id){
                var arg={
                    resultType:"unique",
                    ebOrderItemViewQO: {
                        fetchRegisterGoodsInfo: true  
                    },
                    fetchOrderItems: true,
                    fetchOrg: true,
                    fetchEbPlatform: true,
                    orderNo:id,
                    fetchReportDataChannel: true
                }
               
               QueryOrder(arg).then(res=>{
                   this.form=res.data
               })
            
        },
        editForm(){
            console.log(this.form)
            var form=this.form
            var arg={
                ebOrderId:form.id,
                buyerIdNumber:form.buyerInfo.buyerIdNumber,
                buyerName:form.buyerInfo.buyerName,
                buyerRegNo:form.buyerInfo.buyerRegNo,
                buyerTel:form.buyerInfo.buyerTel,
                ebPlatformId:form.ebPlatform.id,
                freight:form.tradeInfo.freight,
                insureFee:form.tradeInfo.insureFee,
                orderNo:form.tradeInfo.orderNo,
                payChannel:form.tradeInfo.payChannel,
                discount:form.tradeInfo.discount,
                totalWeight:form.tradeInfo.totalWeight,
                payOrderId:form.tradeInfo.payOrderId,
                taxTotal:form.tradeInfo.taxTotal,
                totalAmount:form.tradeInfo.totalAmount,
                tradCounty:form.tradeInfo.tradCounty,
                tradeMode:form.tradeInfo.tradeMode,
                customsChannel:form.reportDataChannel.id,
                orderOrgId:form.declarationInfo.orderOrg.id,
                reportEbPlatformId:form.declarationInfo.orderPlatformOrg.id,
                logisticsOrgId:form.declarationInfo.logisticsOrg.id,
                paymentOrgId:form.declarationInfo.paymentOrg.id,
                invetoryOrgId:form.declarationInfo.invetoryOrg.id,
                createItemCmds:form.items
            }
            console.log(arg)
            ModifyOrder(arg).then(res=>{
                if(res.code==0){
                    this.$message.success('操作成功')
                    this.$emit('reloadData')
                    this.showdetail=false;
                }
            })
        },
        handleClose(){
            this.$emit('closeDialog');
            this.showdetail=false;
            done();
        }
    }
}
</script>
<style scoped>
.title{
    padding-bottom: 3px;
    border-bottom: 1px solid #ebeef5;
    margin-top: 5px;
    margin-bottom: 10px;
}
</style>
